home *** CD-ROM | disk | FTP | other *** search
- /******************************
- File Messenger.c
- By Kirk Chase with ideas from Paul Potts
- Created 9/20/89
-
- Useful routines for dialogs
- *****************************/
-
- #include "Messenger.h"
- #include "pascal.h"
- #include <string.h>
-
- /* variables available globally*/
- DialogInfo MInfo;
- int menu_hieght;
-
- /* PROTOTYPES */
- /* GLOBAL: void MenuBar_Hieght(void)
- used to return menu bar height */
-
- /* GLOBAL: void GetMInfo(DialogInfoPointer theMInfo)
- used to get current MInfo state */
-
- /* GLOBAL: void SetMInfo(DialogInfo theMInfo)
- used to set current MInfo state; use like GetPort() and SetPort() with GetMInfo() */
-
- /* GLOBAL: void SetUpButtons(int numButtons, short theDefault, char *b1, char *b2, char *b3, char *cq);
- used to set up button info in MInfo */
-
- /* GLOBAL: void SetUpRects(int dHor, int dVer, int bHor, int bVer)
- used to set up rectangles in MInfo */
-
- /* GLOBAL: void PositionRect(Rect *smallRect, Rect *largeRect, int HOption, int VOption);
- position small rect in large rect */
-
- /* GLOBAL: int InitMessage()
- general initialization of message structure */
-
- static Rect OriginRect(Rect r);
- /* Moves topleft corner of r to (0,0), while keeping same size, used by ArrangeMessage */
-
- /* GLOBAL: int ArrangeMessage(int horizontal);
- arranges text, 0…1 icons, 0…3 buttons (horizontally, horizontal = 1; vertical, horizontal = 0)
- returns 1 if fine, 0 if problem */
-
- /* GLOBAL: void BoldRect(Rect border);
- Puts bold around a rectangle */
-
- static void HandleUpdate(DialogPtr theDialog);
- /* Used to handle update events while a modal dialog is active. Used by FPROC() */
-
- static pascal Boolean FProc(DialogPtr theDialog,EventRecord *theEvent,int *itemHit);
- /* Filter procedure called by ModalDialog to screen dialog events */
-
- /* GLOBAL: int DoMessage(char *s0, char *s1, char *s2, char *s3);
- main routine for putting up a message box */
-
- /* GLOBAL: int Message(int theType, int theIcon, char *s0, char *s1, char *s2, char *s3)
- handles standard M_OK, M_OK_CANCEL, M_YES_NO, M_YES_NO_CANCEL, M_BUTTONLESS dialogs */
-
- /* GLOBAL: int SaveChanges(char *s1, char *s2)
- handles standard save changes dialog */
-
- /* GLOBAL: char AnOSError(OSErr theError, char *s1, char *s2)
- handles standard OS Error dialog */
-
- /*************************************************************/
- /* Function Defined */
- /*************************************************************/
- /* void MenuBar_Hieght(void)
- used to return menu bar height */
- int MenuBar_Hieght(void)
- {
- #define mBarHeightGlobal 0xBAA
- int *MemPtr, theHieght;
-
- MemPtr = (int *) mBarHeightGlobal;
- if (*MemPtr < 20)
- return(20);
- else
- return(*MemPtr);
- }
-
- /* void GetMInfo(theMInfo)
- used to get current MInfo state; use like GetPort() and SetPort() with SetMInfo() */
- void GetMInfo(theMInfo)
- DialogInfoPointer theMInfo;
- {
- theMInfo->defaultItem = MInfo.defaultItem;
- theMInfo->Buttons = MInfo.Buttons;
- theMInfo->dPlace = MInfo.dPlace;
- theMInfo->dIcon = MInfo.dIcon;
- theMInfo->IconRect = MInfo.IconRect;
- theMInfo->Button1Rect = MInfo.Button1Rect;
- theMInfo->Button2Rect = MInfo.Button2Rect;
- theMInfo->Button3Rect = MInfo.Button3Rect;
- theMInfo->TextRect = MInfo.TextRect;
- theMInfo->dRect = MInfo.dRect;
- theMInfo->Arrange = MInfo.Arrange;
- theMInfo->AddFilter = MInfo.AddFilter;
- strcpy((char *) &theMInfo->Button1, (char *) &MInfo.Button1);
- strcpy((char *) &theMInfo->Button2, (char *) &MInfo.Button2);
- strcpy((char *) &theMInfo->Button3, (char *) &MInfo.Button3);
- strcpy((char *) &theMInfo->CharEquiv, (char *) &MInfo.CharEquiv);
- } /* end of GetMInfo() */
-
- /*************************************************************/
-
- /* void SetMInfo(theMInfo)
- used to set current MInfo state; use like GetPort() and SetPort() with GetMInfo() */
- void SetMInfo(theMInfo)
- DialogInfo theMInfo;
- {
- MInfo.defaultItem = theMInfo.defaultItem;
- MInfo.Buttons = theMInfo.Buttons;
- MInfo.dPlace = theMInfo.dPlace;
- MInfo.dIcon = theMInfo.dIcon;
- theMInfo.IconRect = MInfo.IconRect;
- MInfo.Button1Rect = theMInfo.Button1Rect;
- MInfo.Button2Rect = theMInfo.Button2Rect;
- MInfo.Button3Rect = theMInfo.Button3Rect;
- MInfo.TextRect = theMInfo.TextRect;
- MInfo.dRect = theMInfo.dRect;
- MInfo.Arrange = theMInfo.Arrange;
- MInfo.AddFilter = theMInfo.AddFilter;
- strcpy((char *) &MInfo.Button1, (char *) &theMInfo.Button1);
- strcpy((char *) &MInfo.Button2, (char *) &theMInfo.Button2);
- strcpy((char *) &MInfo.Button3, (char *) &theMInfo.Button3);
- strcpy((char *) &MInfo.CharEquiv, (char *) &theMInfo.CharEquiv);
- } /* end of SetMInfo() */
-
- /*************************************************************/
-
- /* SetUpButtons()
- This sets up text for all 3 buttons and character equivalent, number
- of button and default button of dialog */
- void SetUpButtons(numButtons, theDefault, b1, b2, b3, cq)
- int numButtons;
- short theDefault;
- char *b1, *b2, *b3, *cq;
- {
- MInfo.Buttons = numButtons;
- MInfo.defaultItem = theDefault;
-
- strcpy((char *) &(MInfo.Button1), b1);
- strcpy((char *) &(MInfo.Button2), b2);
- strcpy((char *) &(MInfo.Button3), b3);
- strcpy((char *) &(MInfo.CharEquiv), cq);
- } /* end of SetUpButtons(numButtons, theDefault, b1, b2, b3, cq) */
-
- /*************************************************************/
-
- void SetUpRects(dHor, dVer, bHor, bVer)
- int dHor, dVer, bHor, bVer;
- {
- SetRect(&(MInfo.dRect), 0, 0, dHor, dVer);
- SetRect(&(MInfo.Button1Rect), 0, 0, bHor, bVer);
- SetRect(&(MInfo.Button2Rect), 0, 0, bHor, bVer);
- SetRect(&(MInfo.Button3Rect), 0, 0, bHor, bVer);
- } /* end SetUpRects() */
-
- /*************************************************************/
-
- /* PositionRect()
- Position a smaller rectangle within a larger rectangle
- Options for horizontal (HOption) and vertical (VOption) are as follows:
- 0 : No positioning
- 2, CENTER: center small within large
- 3, THIRD: position in top (or left) third
- */
- void PositionRect(smallRect, largeRect, HOption, VOption)
- Rect *smallRect, *largeRect;
- int HOption, VOption;
- {
- int hoffset, voffset;
-
- /* position horizontally if requested */
- if (HOption != 0) {
- smallRect->right -= smallRect->left;
- smallRect->left = 0;
- hoffset = (largeRect->right - largeRect->left - smallRect->right) / HOption;
- smallRect->left = largeRect->left + hoffset;
- smallRect->right += smallRect->left;
- }
-
- /* position vertically if requested */
- if (VOption != 0) {
- smallRect->bottom -= smallRect->top;
- smallRect->top = 0;
- voffset = (largeRect->bottom - largeRect->top - smallRect->bottom) / VOption;
- smallRect->top = largeRect->top + voffset;
- smallRect->bottom += smallRect->top;
- }
- } /* end of PositionRect(smallRect, largeRect, HOption, VOption) */
-
- /*************************************************************/
-
- /* InitMessage
- General initialization (centered, stop icon, one button)
- You will need to write your own InitMessage for various messages */
- void InitMessage()
- {
- menu_hieght = MenuBar_Hieght();
- MInfo.defaultItem = 1;
- MInfo.Buttons = 1;
- MInfo.dIcon = stopIcon;
- MInfo.dPlace = CENTER;
- MInfo.Arrange = HORIZONTAL;
- MInfo.AddFilter = NULL;
-
- SetRect(&MInfo.dRect, 0, 0, MWidth, MHeight);
- PositionRect(&MInfo.dRect, &(screenBits.bounds), CENTER, CENTER);
-
- SetRect(&MInfo.IconRect, 15, 15, 47, 47);
- SetRect(&MInfo.Button1Rect, 230, 100, 310, 120);
- SetRect(&MInfo.Button2Rect, 125, 100, 205, 120);
- SetRect(&MInfo.Button3Rect, 20, 100, 100, 120);
- SetRect(&MInfo.TextRect, 65, 15, 315, 80);
-
- strcpy((char *) &(MInfo.Button1), "\pOk");
- strcpy((char *) &(MInfo.Button2), "\pCancel");
- strcpy((char *) &(MInfo.Button3), "\pNo");
- strcpy((char *) &(MInfo.CharEquiv), "\poOcCnN");
- } /* end of InitMessage() */
-
- /*************************************************************/
-
- static Rect OriginRect(r)
- Rect r;
- {
- Rect newRect;
-
- SetRect(&newRect, 0, 0, r.right - r.left, r.bottom - r.top);
- return newRect;
- } /* end of OriginRect(r) */
-
- /*************************************************************/
-
- /* ArrangeMessage(); takes MInfo and arranges the rectangles accordingly
- it will look like this:
- __________________ _____________________
- | _________ | | _________ |
- | [I] | Text | | | [I] | Text | (1) |
- | | | | or | | | | according to MInfo.Arrange
- | |________| | | | | (2) |
- | | | | | |
- | (1) (2) (3) | | |________| (3) |
- |_________________| |____________________|
-
- if icon is not around, text is moved over, also if there are no buttons,
- text is moved down.
-
- If all goes well it will return 1, if not, it will return 0 */
- int ArrangeMessage()
- {
- #define MARGIN 10
- #define WSPACE 15
-
- Rect tRdialog, tRicon, tRtext, tRb1, tRb2, tRb3; /* temporary rectangles */
- Rect MaxRect;
- int spacing;
-
- /* place rectangles at origin for easier calculations */
- tRdialog = OriginRect(MInfo.dRect);
- tRicon = OriginRect(MInfo.IconRect);
- tRtext = OriginRect(MInfo.TextRect);
- tRb1 = OriginRect(MInfo.Button1Rect);
- tRb2 = OriginRect(MInfo.Button2Rect);
- tRb3 = OriginRect(MInfo.Button3Rect);
-
- /* set non-used buttons to (0,0,0,0) */
- switch (MInfo.Buttons) {
- case 0:
- SetRect(&tRb1, 0,0,0,0);
- case 1:
- SetRect(&tRb2, 0,0,0,0);
- case 2:
- SetRect(&tRb3, 0,0,0,0);
- default:
- break;
- }
-
- /* get max rectangle of buttons */
- UnionRect(&tRb1, &tRb2, &MaxRect);
- UnionRect(&tRb3, &MaxRect, &MaxRect);
-
- tRtext = tRdialog;
- InsetRect(&tRtext, MARGIN, MARGIN);
-
- if (MInfo.dIcon >= stopIcon) { /* place icon */
- SetRect(&tRicon, 10, 10, 42, 42);
- if ((tRicon.right > tRdialog.right) || (tRicon.bottom > tRdialog.bottom)) {
- return 0;
- }
- /* adjust text for icon and check if there is enough room */
- tRtext.left = tRicon.right + WSPACE;
- if (tRtext.right - tRtext.left < MARGIN) return 0;
- }
- else /* no icon */
- SetRect(&tRicon, 0,0,0,0);
-
- /* figure spacing for buttons */
- if ((MInfo.Buttons > 0) && (MInfo.Arrange == HORIZONTAL)) { /* place buttons horizontally */
- spacing = (tRdialog.right - ((tRb1.right + tRb2.right + tRb3.right) + (MARGIN * 2)))/ (MInfo.Buttons + 1);
-
- /* place buttons */
- SetRect(&tRb1, MARGIN + spacing,
- tRdialog.bottom - tRb1.bottom - MARGIN,
- tRb1.right + MARGIN + spacing,
- tRdialog.bottom - MARGIN);
- SetRect(&tRb2, tRb1.right + spacing,
- tRdialog.bottom - tRb2.bottom - MARGIN,
- tRb2.right + tRb1.right + spacing,
- tRdialog.bottom - MARGIN);
- SetRect(&tRb3, tRb2.right + spacing,
- tRdialog.bottom - tRb3.bottom - MARGIN,
- tRb3.right + tRb2.right + spacing,
- tRdialog.bottom - MARGIN);
-
- /* adjust text recangle for buttons and check if there is enough text room */
- tRtext.bottom = tRdialog.bottom - MARGIN - MaxRect.bottom - WSPACE;
- if (tRtext.bottom - tRtext.top < MARGIN) return 0;
- }
-
- if ((MInfo.Buttons > 0) && (MInfo.Arrange != HORIZONTAL)) { /* place buttons vertically */
- spacing = (tRdialog.bottom - ((tRb1.bottom + tRb2.bottom + tRb3.bottom) + (MARGIN * 2)))/ (MInfo.Buttons + 1);
-
- /* place buttons */
- SetRect(&tRb1, tRdialog.right - MARGIN - tRb1.right,
- MARGIN + spacing,
- tRdialog.right - MARGIN,
- MARGIN + spacing + tRb1.bottom);
- SetRect(&tRb2, tRdialog.right - MARGIN - tRb2.right,
- tRb1.bottom + spacing,
- tRdialog.right - MARGIN,
- tRb1.bottom + spacing + tRb2.bottom);
- SetRect(&tRb3, tRdialog.right - MARGIN - tRb3.right,
- tRb2.bottom + spacing,
- tRdialog.right - MARGIN,
- tRb2.bottom + spacing + tRb3.bottom);
- /* adjust text recangle for buttons and check if there is enough text room */
- tRtext.right = tRdialog.right - MARGIN - MaxRect.right - WSPACE;
- if (tRtext.right - tRtext.left < MARGIN) return 0;
- }
-
- /* return new rectangle values */
- MInfo.IconRect = tRicon;
- MInfo.TextRect = tRtext;
- switch (MInfo.Buttons) {
- case 3:
- MInfo.Button3Rect = tRb3;
- case 2:
- MInfo.Button2Rect = tRb2;
- case 1:
- MInfo.Button1Rect = tRb1;
- default:
- break;
- }
-
- return 1;
- } /* end of int ArrangeMessage() */
-
- /*************************************************************/
-
- /* BoldRect bolds the default button */
- void BoldRect(border)
- Rect border;
- {
- PenNormal();
- PenSize(lineSize, lineSize);
- InsetRect(&border, gapBetween, gapBetween);
- FrameRoundRect(&border, edgeCurve, edgeCurve);
- PenNormal();
- }
-
- /*************************************************************/
-
- /* Handle Update function is used for dialog drawing such as the default button */
- static void HandleUpdate(theDialog)
- DialogPtr theDialog;
- {
- Rect itemRect, theRect;
- int itemType;
- Handle the_item;
- Handle item;
-
- if (MInfo.dIcon >= 0) {
- GetDItem(theDialog, (MInfo.Buttons) + 2, &itemType, &item, &theRect);
- PlotIcon(&theRect, item);
- }
-
- if((MInfo.defaultItem > MInfo.Buttons) || (MInfo.defaultItem == 0)) return;
-
- GetDItem(theDialog, MInfo.defaultItem, &itemType, &the_item, &itemRect);
- BoldRect(itemRect);
- } /* end of HandleUpdate() */
-
- /*************************************************************/
-
- /* FProc is used for filtering Dialog events
- Possible uses include:
- 1. Keyboarde Equivalents for controls.
- 2. Disk initialization.
- 3. Refreshing drawings such as default buttons.
- 4. Mouse tracking.
-
- Returning TRUE means ModalDialog will exit, False means no */
-
- static pascal Boolean FProc(theDialog, theEvent, itemHit)
- DialogPtr theDialog;
- EventRecord *theEvent;
- int *itemHit;
- {
- long key; /* Holds the key code */
- Point ctr; /* where the mouse click will go */
- int DIResult; /* Returned by DIBadMount */
- EventRecord diskEvent; /* Returned by EventAvail, below */
-
- /* Handle disk mounts */
- if (GetNextEvent(diskMask, &diskEvent) == TRUE) {
- if (HiWord(diskEvent.message) != 0) {
- diskEvent.where.h = ((screenBits.bounds.right -
- screenBits.bounds.left) / 2) - (304 / 2);
- diskEvent.where.v = ((screenBits.bounds.bottom -
- screenBits.bounds.top) / 3) - (104 / 2);
- InitCursor();
- DIResult = DIBadMount(diskEvent.where, diskEvent.message);
- }
- } /* end of if GetNextEvent test for disk events */
-
- switch (theEvent->what) {
- case (updateEvt):
- HandleUpdate(theDialog);
- return FALSE;
- break;
-
- case (keyDown):
- key = theEvent->message & charCodeMask;
- switch(key) {
- /* If a key has been pressed, we want to interpret it properly. */
- case theReturnKey: /* Return key */
- case theEnterKey: /* the Enter key */
- *itemHit = MInfo.defaultItem;
- return TRUE; /* exit ModalDialog */
-
- /* Put in other Key equivalents, you may wish to check modifies */
- default:
- if ((MInfo.Buttons > 0) && (theEvent->modifiers & cmdKey))
- if ((key == MInfo.CharEquiv[1]) || (key == MInfo.CharEquiv[2])) {
- *itemHit = 1;
- return TRUE;
- }
- if ((MInfo.Buttons > 1) && (theEvent->modifiers & cmdKey))
- if ((key == MInfo.CharEquiv[3]) || (key == MInfo.CharEquiv[4])) {
- *itemHit = 2;
- return TRUE;
- }
- if ((MInfo.Buttons > 2) && (theEvent->modifiers & cmdKey))
- if ((key == MInfo.CharEquiv[5]) || (key == MInfo.CharEquiv[6])) {
- *itemHit = 3;
- return TRUE;
- }
- SysBeep(5);
- return FALSE;
- } /* end of key code switch */
- break;
-
- case (mouseDown):
- /* You can insert your own mouse click
- handlers here. ModalDialog
- takes care of mouse events, but you can do
- do special processing. For example,
- ModalDialog does nothing if a mouse click
- occurs inside a modal dialog but outside
- of a control, but you could do something.
- Keep in mind that you need to wait for
- mouseUp to determine where the click was
- completed. This gets complex when you
- remember that this procedure is not in
- control, but gets sent each event to filter
- and/or act upon. You would have to use
- static variables to hold events that you
- want to keep track of between calls to
- your filterProc. */
-
- /* if there are no buttons, dismiss dialog with a mouse click */
- if (MInfo.Buttons == 0) {
- *itemHit = MInfo.defaultItem;
- return TRUE;
- }
- return FALSE;
- break;
-
- case (mouseUp):
- return FALSE;
- break;
-
- default:
- return FALSE;
- break;
- /* We don't handle any other types of events, so
- these get sent to ModalDialog unchanged. */
-
- } /* end of switch */
-
- } /* end of filterproc function */
-
- /*************************************************************/
-
- /* Do Message is a function to handle various 0-3 button message dialogs
- returns last item hit in dialog or 0 if something went wrong */
- int DoMessage( s0, s1, s2, s3)
- char *s0, *s1, *s2, *s3;
- {
- int itemHit, itemNo, itemType;
- int exitDialog, DLOGno;
- Rect theRect;
- DialogPtr theDialog;
- Handle theDITL, item, icon;
- DialogTHndl dth;
- WindowPtr oldWindow;
-
- /* get icon if needed */
- DLOGno = MessageBase + MInfo.Buttons;
- if (MInfo.dIcon >= 0) {
- DLOGno += 10;
- icon = GetIcon(MInfo.dIcon);
- if (icon == NULL)
- SysBeep(5);
- if (ResError() != noErr) return (0);
- HLock(icon);
- }
-
- dth = (DialogTHndl) GetResource('DLOG', DLOGno);
- if (ResError() != noErr) return(0);
- HLock((Handle) dth);
-
- GetPort(&oldWindow);
-
- theRect = screenBits.bounds;
- theRect.top += menu_hieght;
- if ((MInfo.dPlace == CENTER) || (MInfo.dPlace == THIRD))
- PositionRect(&(MInfo.dRect), &(theRect), CENTER, MInfo.dPlace);
-
- /* set up DLOG template's bounds rectangle */
- (*dth)->boundsRect = MInfo.dRect;
-
- theDialog = GetNewDialog(DLOGno, 0, (WindowPtr) -1); /*will get modified rect*/
- if (theDialog == NULL) {
- SetPort(oldWindow);
- HUnlock((Handle) dth);
- ReleaseResource((Handle) dth);
- return (0);
- }
-
- /* arrange the dialog items in MInfo */
- if (ArrangeMessage() == 0) return (0);
-
- /* set up title buttons */
- switch (MInfo.Buttons) {
- case 3:
- GetDItem(theDialog, 3, &itemType, &item, &theRect);
- SetCTitle((ControlHandle) item, MInfo.Button3);
- theRect = MInfo.Button3Rect;
- (**((ControlHandle)item)).contrlRect = theRect;
- SetDItem(theDialog, 3, itemType, item, &theRect);
- case 2:
- GetDItem(theDialog, 2, &itemType, &item, &theRect);
- SetCTitle((ControlHandle) item, MInfo.Button2);
- theRect = MInfo.Button2Rect;
- (**((ControlHandle)item)).contrlRect = theRect;
- SetDItem(theDialog, 2, itemType, item, &theRect);
- case 1:
- GetDItem(theDialog, 1, &itemType, &item, &theRect);
- SetCTitle((ControlHandle) item, MInfo.Button1);
- theRect = MInfo.Button1Rect;
- (**((ControlHandle)item)).contrlRect = theRect;
- SetDItem(theDialog, 1, itemType, item, &theRect);
- default:
- break;
- }
-
- /* set up icon if needed */
- if (MInfo.dIcon >= 0) {
- GetDItem(theDialog, (MInfo.Buttons) + 2, &itemType, &item, &theRect);
- theRect = MInfo.IconRect;
- item = icon;
- SetDItem(theDialog, (MInfo.Buttons) + 2, itemType, item, &theRect);
- }
-
- /* set up text */
- GetDItem(theDialog, MInfo.Buttons + 1, &itemType, &item, &theRect);
- theRect = MInfo.TextRect;
- SetDItem(theDialog, MInfo.Buttons + 1, itemType, item, &theRect);
- ParamText(s0, s1, s2, s3);
-
- /* set up exit flag and do Modal Dialog */
- exitDialog = FALSE;
- ShowWindow(theDialog);
- SelectWindow(theDialog);
- SetPort(theDialog);
- FlushEvents(everyEvent, 0);
-
- /* Actual Dialog Loop */
- while (!exitDialog) {
- ModalDialog((ProcPtr) FProc, &itemHit);
-
- /* further checks and handling */
- if (MInfo.AddFilter == NULL) {
- if (itemHit <= MInfo.Buttons) exitDialog = TRUE; /* exit on any button pressed */
- }
- else {
- exitDialog = CallPascalB(itemHit, theDialog, MInfo.AddFilter);
- }
-
- if (itemHit == MInfo.defaultItem) exitDialog = TRUE; /* exit on default item */
- }
-
- /* dispose of resources */
- DisposDialog(theDialog);
- if (icon != NULL) {
- HUnlock(icon);
- ReleaseResource(icon);
- }
- HUnlock((Handle) dth);
- ReleaseResource((Handle) dth);
- SetPort(oldWindow);
- return itemHit;
- } /* end of DoMessage( s0, s1, s2, s3) */
-
- /*************************************************************/
-
- /* Message() Handles standard ok, ok/cancel, yes/no,
- yes/no/cancel dialogs */
- int Message(theType, theIcon, s0, s1, s2, s3)
- int theType, theIcon;
- char *s0, *s1, *s2, *s3;
- {
- DialogInfo tempInfo, oldInfo; /* MInfo stuff */
- int theAnswer;
- WindowPtr savePort;
-
- GetMInfo(&oldInfo);
-
- tempInfo.dIcon = theIcon;
- tempInfo.Arrange = HORIZONTAL;
- tempInfo.AddFilter = NULL;
- tempInfo.dPlace = THIRD;
- SetMInfo(tempInfo);
-
- switch (theType) {
- case M_BUTTONLESS:
- SetUpButtons(0, 0, "\p", "\p", "\p", "\p");
- SetUpRects(250, 100, 0, 0);
- break;
- case M_OK:
- SetUpButtons(1, 1, "\pOK", "\p", "\p", "\pOoOoOo");
- SetUpRects(250, 150, 60, 20);
- break;
- case M_OK_CANCEL:
- SetUpButtons(2, 1, "\pOK", "\pCancel", "\p", "\pOoCcOo");
- SetUpRects(250, 150, 60, 20);
- break;
- case M_YES_NO:
- SetUpButtons(2, 1, "\pYes", "\pNo", "\p", "\pYyNnOo");
- SetUpRects(250, 150, 60, 20);
- break;
- case M_YES_NO_CANCEL:
- SetUpButtons(3, 1, "\pYes", "\pNo", "\pCancel", "\pYyNnCc");
- SetUpRects(300, 150, 60, 20);
- break;
- default:;
- }
-
- GetPort(&savePort);
- theAnswer = DoMessage(s0, s1, s2, s3);
- SetPort(savePort);
- SetMInfo(oldInfo);
- return(theAnswer);
- } /* end Message() */
-
- /*************************************************************/
-
- /* SaveChanges() Handles standard yes/no/cancel.
- "Save changes to
- <FileName>
- <before closing? | before quitting?>" */
- int SaveChanges(s1, s2)
- char *s1, *s2;
- {
- int theAnswer;
-
- theAnswer = Message(M_YES_NO_CANCEL, cautionIcon, "\pSave changes to", s1, s2, "\p");
-
- return(theAnswer);
- } /* end SaveChanges() */
-
- /*************************************************************/
-
- /* AnOSError() Handles OS error reporting.
- Returns TRUE if error, else FALSE (no error) */
- char AnOSError(theError, s1, s2)
- OSErr theError;
- char *s1, *s2;
- {
- char anError;
- Str255 s4;
- int theAnswer;
-
- anError = FALSE;
- if (theError != noErr) {
- InitCursor();
- anError = TRUE;
- NumToString((long) theError, &s4);
- theAnswer = Message(M_OK, noteIcon, s1, s2, "\pOS error # is", (char *) &s4);
- }
- return(anError);
- }